	 <?php 
     	if(!isset($_SESSION)) 
	{ 
		session_start(); 
	}
if(!isset($_SESSION['db'])){
	$addressbrowser = $_SERVER['SERVER_NAME'];
	$temp = explode(".", $addressbrowser);
	$connection = mysql_connect("1.234.53.52", "cam", "5678" ) ;
	//$connection = mysql_connect("localhost", "root", "root" ) ;
	mysql_select_db("elihan", $connection);
	mysql_query("set names 'utf8'");
	$selectdatabase = mysql_query("SELECT am.DatabaseName,am.Logo from ac_eli_manager am where am.KeyName='$temp[0]' and am.`Status` = 2");
	$result = mysql_fetch_assoc($selectdatabase);

	$_SESSION['Logo']=$result[Logo];
		
	$_SESSION['db']= $result[DatabaseName];
	mysql_close($connection);
}
$database = $_SESSION['db'];
//include("handle/get_number_list.php");
$mysqli = new mysqli("1.234.53.52", "cam", "5678","$database");
//$mysqli = new mysqli("localhsot", "root", "root","$database");

$query = mysqli_query($mysqli,"call getTotalDocument($id_employee)");
while($row = mysqli_fetch_array($query)){
	$num_re_pending = $row[RePendingDoc];
	$num_re_not_approve = $row[ReNotApprovedDoc];
	$num_re_approved= $row[ReApprovedDoc];

	$num_meeting= $row[ReMeetingDoc];
	$num_re_declined = $row[ReDeclinedDoc];
	$num_re_reference_approved = $row[ReRefApprovedDoc];
	$num_re_reference_waiting = $row[ReRefWaitingDoc];
	$num_re_received_metting = $row[ReMeetingDoc];


	$num_my_sendingDoc=$row[MySendingDoc];
	$num_my_savedDoc=$row[MySavedDoc];
	$num_my_approveDoc=$row[MyApproveDoc];
	$num_my_declinedDoc=$row[MyDeclinedDoc];
	$num_my_meetingDoc=$row[MyMeetingDoc];

	$num_bin_re_doc = $row[BinReceiverDoc];
	$num_bin_se_doc = $row[BinSendingDoc];
}

$mysqli->close();
		include 'operations/connection.php';
		$query1 =mysql_query("SELECT p.IDProject, p.NameProject, p.Description, p.DateStart, p.DateComplete, p.IDManager, p.Status
		 FROM pr_project p,pr_composition c, employee e  WHERE ((c.IDEmployee = '$id_employee'  AND e.IDEmployee = c.IDEmployee) or (p.IDManager='$id_employee' and e.IDEmployee=p.IDManager)) AND p.IDProject = c.IDProject GROUP BY p.IDProject ORDER BY p.NameProject ASC");

		mysql_query("UPDATE listapprove SET IDLabel = IDStatus WHERE IDStatus > 10");
		mysql_query("UPDATE listapprove SET IDStatus=1 WHERE IDStatus > 10");
		$sql="SELECT l.IDLable,l.LableName,
		(SELECT COUNT(*) FROM approvedoc a WHERE a.IDLabel=l.IDLable) as slApprove,
		(SELECT COUNT(*) FROM listapprove la,approvedoc a WHERE la.IDLabel=l.IDLable AND a.IDGroupApprove=la.IDGroupApprove AND la.IDEmployee='$id_employee') as slgApprove,
		(SELECT COUNT(*) FROM list_reference lr,approvedoc a WHERE lr.IDLabel=l.IDLable AND a.IDGroupApprove=lr.id_group AND lr.id_employee='$id_employee') as slreference
		FROM list_lable l WHERE l.IDEmployee='$id_employee';";
		$manglibrary=mysql_query($sql);
     	$sql="SELECT b.isView
		 	FROM approvedoc a ,listapprove b , employee e
			WHERE b.IDEmployee = '$id_employee' AND a.IDTypeDoc != 11 AND a.IDStatus= 2 AND b.IDStatus= 2 AND a.IDGroupApprove = b.IDGroupApprove AND a.IDEmployee = e.IDEmployee  AND b.isView=0";
     	
			$notappmysql=mysql_query($sql);
			$sql="SELECT a.isView
						FROM approvedoc a,employee e 
						WHERE a.IDEmployee=e.IDEmployee  and a.IDLabel<1 AND a.IDEmployee='$id_employee' AND a.IDStatus=1 AND a.isView=0;";
			$myappmysql=mysql_query($sql);
			$sql="SELECT a.isView
						FROM approvedoc a,employee e 
						WHERE a.IDEmployee=e.IDEmployee AND a.IDEmployee='$id_employee' AND a.IDStatus=3 and  a.IDLabel < 1 AND a.isView=0;";
			$mydecmysql=mysql_query($sql);
     ?>
<script type="text/javascript">
        $(document).ready(function() {
            $('.sub_app_mo').hide();
            $('.app_tt:first').addClass('active');
            
            $('.app_tt').click(function() {
                $('.active').removeClass('active');
                $('.sub_app_mo').slideUp('normal');
                if($(this).next('.sub_app_mo').is(':hidden') == true) {
                $(this).addClass('active');
                $(this).next('.sub_app_mo').slideDown('normal');
                }
            });
            $('.app_tt').hover(function(){//over
                $(this).addClass('on');
            },function() {//out
                $(this).removeClass('on');
            });
            
            $('#<?=$append?>').click();
        });
        
     </script>
    
       	<div class="nav_top">
       		<div class="nav_tit"><?php echo $l_e_approval?></div>     
            <div class="rehome"><a href="mainPhone.php"><?php echo $l_menu?></a></div>       
       	</div>
        <div class="main_app">
        	<h1><span class="top_col"></span>
        	 <div class="app_tt" id="myhome" style="background:  url('images/icon_right.png') no-repeat scroll left center transparent;padding-left:23px;line-height:30px;">
        	 	<a href="ApproveMain.php" style="padding-left: 0px;"><?=$l_main ?></a></div>
        	</h1>
            <h1>
            	<span class="top_col"></span>
                <div class="app_tt" id="receivedDocument" style="background:  url('images/icon_down.png') no-repeat scroll left center transparent;padding-left:23px;line-height:30px;"><?=$l_received_document?></div>     
                <ul class="sub_app_mo">
                	<li><a href="received.php?content=list-receiver-pending-content" style="padding-left: 28px;"><?=$l_pending_document?> (<?=$num_re_pending?>)</a></li>
                    <li><a href="received.php?content=list-receiver-not-approved-content"><?=$l_not_approved_document?> (<?php if (mysql_num_rows($notappmysql)==0){?>
																															<?=$num_re_not_approve?> <?php }else{?> <b><?=$num_re_not_approve?>
																															</b> <?php }?>)       
                    </a></li>
                    <li><a href="received.php?content=list-receiver-approved-content"><?=$l_approved_document?> (<?=$num_re_approved?>)</a></li>
                    <li><a href="received.php?content=list-receiver-declined-content"><?=$l_declined_document?> (<?=$num_re_declined?>)</a></li>
                    <li><a href="received.php?content=list-receiver-reference-approved-content"><?=$l_reference_document_approved?> (<?=$num_re_reference_approved?>)</a></li>
                    <li><a href="received.php?content=list-receiver-reference-waiting-content"><?=$l_reference_document_waiting?> (<?=$num_re_reference_waiting?>)</a></li>
                    <li><a href="received.php?content=list-receiver-meeting-pending-content"><?=$l_meeting_document?> (<?=$num_re_received_metting?>)</a></li>
                </ul>           
            </h1>
            
             <h1>
            	<span class="top_col"></span>
                <div class="app_tt" id="mydocumentDocument" style="background:  url('images/icon_down.png') no-repeat scroll left center transparent;padding-left:23px;line-height:30px;"><?php echo $l_my_document;?></div>
                <ul class="sub_app_mo" >
                	<li><a href="mydocument.php?content=list-mydocument-sending-content"><?=$l_my_sendingDoc?> (<?=$num_my_sendingDoc?>)</a></li>
                    <li><a href="mydocument.php?content=list-mydocument-saved-content"><?=$l_my_savedDoc?> (<?=$num_my_savedDoc?>)</a></li>
                    <li><a href="mydocument.php?content=list-mydocument-approved-content"><?=$l_my_approveDoc?> (<?php if (mysql_num_rows($myappmysql)==0){?>
																	<?=$num_my_approveDoc?> <?php }else{?> <b><?=$num_my_approveDoc?>
															</b> <?php }?>)
                    </a></li>
                    <li><a href="mydocument.php?content=list-mydocument-declined-content"><?=$l_my_declinedDoc?> (<?php if (mysql_num_rows($mydecmysql)==0){?>
																	<?=$num_my_declinedDoc?> <?php }else{?> <b><?=$num_my_declinedDoc?>
														</b> <?php }?>)
                    </a></li>
                    <li><a href="mydocument.php?content=list-mydocument-meeting-sending-content"><?=$l_my_meetingDoc?> (<?=$num_my_meetingDoc?>)</a></li>
                </ul>
            </h1>
            <h1>
            	<span class="top_col"></span>
                <div class="app_tt" id="mybinDocument" style="background:  url('images/icon_down.png') no-repeat scroll left center transparent;padding-left:23px;line-height:30px;"><?php echo $l_re_bin;?></div>
                <ul class="sub_app_mo" >
                	<li><a href="mybin.php?content=list-mybin-recedoc-content"
									><?=$l_re_document?> (<?=$num_bin_re_doc?> )</a></li>
                    <li><a href="mybin.php?content=list-mybin-senddoc-content"><?=$l_se_document?>
										(<?=$num_bin_se_doc?>)</a></li>
                </ul>
            </h1>
            <h1>
            	<span class="top_col" ></span>
                <div class="app_tt" id="libraryDocument" style="background:  url('images/icon_down.png') no-repeat scroll left center transparent;padding-left:23px;line-height:30px;"><?php echo $l_li_document;?></div>
                <ul class="sub_app_mo">
               		 <li><span><a
									href="create-newlabel.php"><?=$l_new_label?> </a> </span>
					 </li>
                	<?php

						if(count($manglibrary)>0){
							$vitri=1;
							while($row=mysql_fetch_array($manglibrary)){
								?>
							<li class="last">
								<table style="width: 100%; border: 1;">
									<tr>
										<td><span>
									<a href="library.php?content=list-library-content&liname=<?php echo $row[LableName];?>&libraryid=<?php echo $row[IDLable];?>"><?php echo $row[LableName]?>
												<?php
												$soluong=$row[slApprove]+$row[slgApprove]+$row[slreference];
												echo " ( ".$soluong." )";
												?> 
									</a></span><span style="float: right;margin-top: -20px;">
											<a href="edit-label.php?idlabel=<?=$row[IDLable]?>&name=<?=$row[LableName]?>">
												<img src="images/config.png" alt="" style="width: 9px;height: 9px;" /> </a> </span>
													</td>
									</tr>
								</table>
							</li>
							<?php
							}
						}
						?>
                </ul>
            </h1>
            
            
        </div>   
        <?php mysql_close($connection); ?>
